package com.jiutong.meipengdai.ui.activitys;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.jiutong.meipengdai.R;
import com.jiutong.meipengdai.base.BaseActivity;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 作用:
 * Created by 78 on 2017/6/1.
 */
public class HouseActivity extends BaseActivity implements View.OnClickListener {

    @Bind(R.id.et_house)
    EditText et_house;
    @Bind(R.id.iv_clean)
    ImageView iv_clean;
    @Bind(R.id.tv_exist_house)
    TextView tv_exist_house;
    @Bind(R.id.iv_back)
    ImageView iv_back;
    @Bind(R.id.tv_title)
    TextView tv_title;
    @Bind(R.id.btn_house_submit)
    Button btn_house_submit;

    private final static int XIAO_QU =1;

    @Override
    public int getLayoutResouceId() {
        return R.layout.evaluate_house;
    }

    @Override
    protected void initView() {
        super.initView();
        ButterKnife.bind(this);
        tv_title.setText("小区");
    }

    @Override
    protected void initEvent() {
        super.initEvent();
        iv_clean.setOnClickListener(this);
        tv_exist_house.setOnClickListener(this);
        iv_back.setOnClickListener(this);
        btn_house_submit.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_clean:
                et_house.setText("");
                break;
            case R.id.tv_exist_house:
                et_house.setText(tv_exist_house.getText());
                break;
            case R.id.iv_back:
                finish();
                break;
            case R.id.btn_house_submit:
                submit();
                break;
        }
    }

    private void submit() {
        if(et_house.getText().toString().equals("")){
            Toast.makeText(this,"请输入小区名称",Toast.LENGTH_SHORT).show();
        }else {
            Intent intent = new Intent();
            String house = et_house.getText().toString();
            intent.putExtra("house",house);
            setResult(XIAO_QU,intent);
            finish();
        }
    }
}

